package cn.collection.set;

import java.util.LinkedHashSet;

public class Demo14 {
    public static void main(String[] args) {
        // 1.创建4个学生对象
        Student2 s1 = new Student2("zhangsan", 23);
        Student2 s2 = new Student2("lisi", 24);
        Student2 s3 = new Student2("wangwu", 25);
        Student2 s4 = new Student2("zhangsan", 23);


        // 2.创建集合的对象
        LinkedHashSet<Student2> lhs = new LinkedHashSet<>();


        // 3.添加元素
        System.out.println(lhs.add(s3));
        System.out.println(lhs.add(s2));
        System.out.println(lhs.add(s1));
        System.out.println(lhs.add(s4));

        // 4.打印集合
        System.out.println(lhs);
    }
}
